package com.zjitc.bookshop39.controller;


import com.zjitc.bookshop39.entity.User;
import com.zjitc.bookshop39.service.UserService;
import com.zjitc.bookshop39.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 * 提供基本的用户管理功能
 */
@RestController

public class UserController {

    @Autowired
    private UserService userService;
    //login
    @PostMapping("/login")
    public ApiResponse<String> login(@RequestBody User user){
        String Jwt = userService.login(user);
        if (Jwt!=null){
            return ApiResponse.success("Success",Jwt);
        }
        return  ApiResponse.error(401,"用户名或者密码错误");

    }
} 